local require = require
local math = math
local env     = require("modules.env.env")
local config  = require("modules.business_common.config.config" .. env.debug)

-- desc : 商业化通用配置，获取默认的配置信息

local FOO = {
    _VERSION = '0.0.1',
    ENV = {
        CHINESE_RELEASE =  0,       -- 国内正式环境
        CHINESE_DEBUG   =  1,       -- 国内测试环境
        OVERSEA_RELEASE = 10,       -- 海外正式环境
        OVERSEA_DEBUG   = 11,       -- 海外测试环境
    }
}

--!@ 当前是否测试环境
FOO.debug_env = function ()
    return env.debug == FOO.ENV.CHINESE_DEBUG
        or env.debug == FOO.ENV.OVERSEA_DEBUG
end


local url_by_uin = function (severs, uin)
    return severs and severs[(uin % #severs) + 1] or nil
end

local url_random = function (servers)
    local index = #servers > 1 and math.random(#servers) or 1
    return servers[index]
end

--!@ 获取账户消耗相关接口url
FOO.get_cost_server_url = function ( uin )
    return url_by_uin(config.gm_cost_server_url, uin)
end

--!@ 获取资产管理服相关接口url
FOO.capital_mgr_enabled = config.capital_mgr_enabled
FOO.get_asset_server_url = function ( uin )
    return url_by_uin(config.gm_asset_server_url, uin)
end

--!@ 获取avatar url
FOO.get_avatar_server_url = function(uin)
    return url_by_uin(config.query_avatar_url, uin)
end


--!@ 获取profile url
FOO.get_profile_server_url = function(uin)
    return url_by_uin(config.query_profile_url, uin)
end


--!@ 获取商城服url
FOO.get_mall_server_url = function (uin)
    return url_by_uin(config.mall_url, uin)
end


--!@ 获取商城服url
FOO.get_business_server_url = function (uin)
    return url_by_uin(config.business_url, uin)
end


--!@ 获取老福利服url
FOO.get_ma_server_url = function (uin)
    return url_by_uin(config.ma_server_url, uin)
end


--!@ 获取邮件服url
FOO.get_mail_server_url = function (uin)
    return url_by_uin(config.mail_server_url, uin)
end


--!@ 获取邮件服url
FOO.get_manor_server_url = function (uin)
    return url_by_uin(config.manor_url, uin)
end


-- !@ 获取云服url
FOO.get_cloud_server_url = function ()
    return url_random(config.cloud_server_url)
end


-- !@ 获取推送服url
FOO.get_push_send_server_url = function ()
    return url_random(config.push_send_server_url)
end


FOO.get_developers_server_url = function ()
    return url_random(config.developers_server_url)
end

-- 是否启用资产查询服功能
FOO.capital_server_enable = config.capital_server_enable
FOO.get_capital_server_url = function (uin)
    return url_by_uin(config.capital_server_url, uin)
end

--!@ 获取福利服url
FOO.get_welfare_server_url = function ()
    return config.bu_welfare_url
end

FOO.get_rank_url = function ()
    return config.business_rank
end

return FOO